package net.zigin.nhi.could.waste.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.zigin.commons.util.ReflectUtil;
import net.zigin.nhi.could.waste.dto.SysUserAdminDto;
import net.zigin.nhi.could.waste.model.SysUserAdmin;
import net.zigin.nhi.could.waste.service.SysUserAdminService;

import net.zigin.nhi.could.waste.vo.SysUserAdminVo;
import net.zigin.nhi.could.waste.vo.JsonForResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * SysUserAdmin控制器类
 * @ClassName: SysUserAdminController
 * @author mgw1986
 * @date 2021-9-7 19:08:57
 * @version V1.0
 */
@Api(tags = "监管端管理员管理")
@RestController
@RequestMapping("/sysUserAdmin")
public class SysUserAdminController extends BaseController {
	@Autowired
	private SysUserAdminService sysUserAdminService;

	/**
	 * 新增编辑监管端管理员
	 *
	 * @param sysUserAdminDto 监管端管理员信息
	 * @return 监管端管理员ID
	 */
	@ApiOperation("新增编辑监管端管理员")
	@ApiImplicitParam(name = "sysUserAdminDto", value = "监管端管理员信息", required = true, dataType = "SysUserAdminDto")
	@PostMapping("/save")
	public JsonForResult<String> sava(@RequestBody SysUserAdminDto sysUserAdminDto) {
		String id = sysUserAdminService.saveOrUpdate(sysUserAdminDto);
		return JsonForResult.<String>builder().data(id).success(true).build();
	}

	/**
	 * 监管端管理员列表
	 *
	 * @param sysUserAdminDto 监管端管理员信息
	 * @return 监管端管理员列表
	 */
	@ApiOperation("监管端管理员列表")
	@ApiImplicitParam(name = "sysUserAdminDto", value = "监管端管理员信息", required = true, dataType = "SysUserAdminDto")
	@PostMapping("/getList")
	public JsonForResult<List<SysUserAdminVo>> getList(@RequestBody SysUserAdminDto sysUserAdminDto) {
		List<SysUserAdminVo> list = sysUserAdminService.getList(sysUserAdminDto);
		Integer count = sysUserAdminService.getCount(sysUserAdminDto);
		return JsonForResult.<List<SysUserAdminVo>>builder()
				.data(list).total(count)
				.success(true).build();
	}

	/**
	 * 监管端管理员详情
	 *
	 * @param id ID
	 * @return 监管端管理员详情
	 */
	@ApiOperation("监管端管理员详情")
	@ApiImplicitParam(name = "id", value = "监管端管理员id", required = true, dataType = "String")
	@GetMapping("/getById/{id}")
	public JsonForResult<SysUserAdminVo> getById(@PathVariable String id) {
		SysUserAdminVo sysUserAdminVo = sysUserAdminService.getInfoById(id);
		return JsonForResult.<SysUserAdminVo>builder().data(sysUserAdminVo).success(true).build();
	}

	/**
	 * 删除监管端管理员
	 *
	 * @param id ID
	 * @return
	 */
	@DeleteMapping("/remove/{id}")
	@ApiOperation("删除监管端管理员")
	@ApiImplicitParam(name = "id", value = "监管端管理员id", required = true, dataType = "String")
	public JsonForResult remove(@PathVariable String id) {
		sysUserAdminService.remove(id);
		return JsonForResult.builder().success(true).build();
	}



}
